package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Refund;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RefundDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主表id")
    private Integer id;

    @ApiModelProperty(value = "生产单id")
    private Integer produceId;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "退款标题")
    private String title;

    @ApiModelProperty(value = "退款原由")
    private String reason;

    @ApiModelProperty(value = "退款金额")
    private Double refundMoney;

    @ApiModelProperty(value = "退款人")
    private Integer refundAdminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "状态：0待审核，1通过，2不通过，3作废，4，删除")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "合同编码")
    private String contractCode;


    @ApiModelProperty(value = "客户名称")
    private String customerName;


    @ApiModelProperty(value = "退钱人")
    private String refundAdminName;


    @ApiModelProperty(value = "退钱产品列表")
    private List<RefundProductDTO> refundProducts;


    public RefundDTO() {}

    public RefundDTO(Refund entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static RefundDTO convert(Refund entity) {
        return new RefundDTO(entity);
    }

    public static List<RefundDTO> convertList(List<Refund> list) {
        List<RefundDTO> resultList = new ArrayList<>();
        for (Refund entity : list) {
            resultList.add(new RefundDTO(entity));
        }
        return resultList;
    }}
